home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / initresident.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  97 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: initresident.c,v 1.4 1996/08/13 13:56:03 digulla Exp $
  4.     $Log: initresident.c,v $
  5.     Revision 1.4  1996/08/13 13:56:03  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.3  1996/08/01 17:41:12  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang:
  15. */
  16. #include <dos/dos.h>
  17. #include <aros/libcall.h>
  18. #include "exec_intern.h"
  19.  
  20. /*****************************************************************************
  21.  
  22.     NAME */
  23.     #include <exec/resident.h>
  24.     #include <clib/exec_protos.h>
  25.  
  26. __AROS_LH2(APTR, InitResident,
  27.  
  28. /*  SYNOPSIS */
  29.     __AROS_LHA(struct Resident *, resident, A1),
  30.     __AROS_LHA(BPTR,              segList,  D1),
  31.  
  32. /* LOCATION */
  33.     struct ExecBase *, SysBase, 17, Exec)
  34.  
  35. /*  FUNCTION
  36.     Test the resident structure and build the library or device
  37.     with the information given therein. The Init() vector is
  38.     called and the base address returned.
  39.  
  40.     INPUTS
  41.     resident - Pointer to resident structure.
  42.     segList  - Pointer to loaded module, 0 for resident modules.
  43.  
  44.     RESULT
  45.     A pointer to the library or device ready to add to the exec lists.
  46.  
  47.     NOTES
  48.  
  49.     EXAMPLE
  50.  
  51.     BUGS
  52.  
  53.     SEE ALSO
  54.  
  55.     INTERNALS
  56.  
  57.     HISTORY
  58.  
  59. ******************************************************************************/
  60. {
  61.     __AROS_FUNC_INIT
  62.  
  63.     /* Check for validity */
  64.     if(resident->rt_MatchWord!=RTC_MATCHWORD||
  65.        resident->rt_MatchTag!=resident)
  66.     return NULL;
  67.  
  68.     /* Depending on the autoinit flag... */
  69.     if(resident->rt_Flags&RTF_AUTOINIT)
  70.     {
  71.     /* ...initialize automatically... */
  72.     struct init
  73.     {
  74.         ULONG dSize;
  75.         APTR vectors;
  76.         APTR structure;
  77.         ULONG_FUNC init;
  78.     };
  79.     struct init *init=(struct init *)resident->rt_Init;
  80.     struct Library *library;
  81.     library=MakeLibrary(init->vectors,init->structure,
  82.                 init->init,init->dSize,segList);
  83.     if(library!=NULL)
  84.     {
  85.         library->lib_Node.ln_Type=resident->rt_Type;
  86.         library->lib_Node.ln_Name=resident->rt_Name;
  87.         library->lib_Version     =resident->rt_Version;
  88.         library->lib_IdString    =resident->rt_IdString;
  89.     }
  90.     return library;
  91.     }else
  92.     /* ...or let the library do it. */
  93.     return __AROS_ABS_CALL3(struct Library *,resident->rt_Init,NULL,D0,
  94.                 segList,A0,SysBase,A6);
  95.     __AROS_FUNC_EXIT
  96. } /* InitResident */
  97.